<?php
$result = RequestData('forschung');
$ressource = RequestData('resource');
?>
<form method="POST">
	<table class="buildings" style="table-layout: fixed; width: 720px;">
		<colgroup>
			<col style="width:115px;">
			<col style="width:auto;">
			<col style="width:100px">
		</colgroup>
		<thead>
			<td>Forschungs-Zentrum</td>
		</thead>
		<?php
			$con = Connect();
			$check = mysql_query("SELECT * FROM forschung_build ORDER BY Name");
			while($object = mysql_fetch_object($check))
			{
				$lock = array(false, false, false, false);
				if($object->Name == 'Radar' && $result['Radar'] >= 10)
				{
					echo '<tr><th><img src="../Game/template/Images/forschung/'.$object->Name.'.png"></th>';
					echo '<th><p>'.$object->Name.'['.$result[$object->Name].']</p><p>'.$object->Description.'</p></th><th></th>';
				}else{
					echo '<tr><th><img src="../Game/template/Images/forschung/'.$object->Name.'.png"></th>';
					echo '<th><p>'.$object->Name.'['.$result[$object->Name].']</p><p>'.$object->Description.'</p>';
					echo '<p>Zeit: '.$object->Time.'</p><p>Ressourcen: ';
					if($ressource['Credits'] < $object->Credits)
					{
						echo '<b style="color:#FF0000;">'.$object->Credits.' Credits</b>, ';
						$lock[0] = true;
					}else{
						echo '<b style="color:#00FF00;">'.$object->Credits.' Credits</b>, ';
					}
					if($ressource['Titan'] < $object->Titan)
					{
						echo '<b style="color:#FF0000;">'.$object->Titan.' Titan</b>, ';
						$lock[1] = true;
					}else{
						echo '<b style="color:#00FF00;">'.$object->Titan.' Titan</b>, ';
					}
					if($ressource['Oel'] < $object->Oel)
					{
						echo '<b style="color:#FF0000;">'.$object->Oel.' &Ouml;l</b>';
						$lock[2] = true;
					}else{
						echo '<b style="color:#00FF00;">'.$object->Oel.' &Ouml;l</b>';
					}
					if($object->Benzin != 0)
					{
						if($ressource['Benzin'] < $object->Benzin)
						{
							echo ', <b style="color:#FF0000;">'.$object->Benzin.' Benzin</b></p></th>';
							$lock[3] = true;
						}else{
							echo ', <b style="color:#00FF00;">'.$object->Benzin.' Benzin</b></p></th>';
						}
					}else{ echo '</p></th>'; }
					echo '</th><th><p><input class="button" type="submit" name="'.$object->Name.'" value="Stufe '.++$result[$object->Name].'" style="width:80px;" ';
					if($lock[0] == true || $lock[1] == true || $lock[2] == true || $lock[3] == true) echo 'disabled';
					echo '></p></th></tr>';
				}
			}
			Close($con);
		?>
	</table>
</form>